import { Controller, Get, Query, Req } from '@nestjs/common';
import { Coupon_Service } from '../coupon/coupon.service';
import { ApiTags } from '@nestjs/swagger';
import { util_ApiResponse_Base } from '@/common/util/apiResponse';
import { IRequest } from '@/common/typeScripts';
import { util_Index_ReturnContent } from '@/common/util';
import { Others_PageClass_Base } from '@/common/others/pageClass';
import { Coupon_Web_Find_Dto } from '../coupon/assets/coupon.dto';

@Controller('/web/couponWeb')
@ApiTags('couponWeb 优惠券')
export class CouponWeb_Controller {
  constructor(private readonly coupon_Service: Coupon_Service) {}

  @Get('/myCoupon')
  @util_ApiResponse_Base({
    dataType: 'dataType_list',
    summary: '查询我的优惠券,根据商品查询优惠券',
  })
  async couponWeb_MyCoupon(@Req() req: IRequest, @Query() query: Coupon_Web_Find_Dto) {
    return util_Index_ReturnContent(await this.coupon_Service.coupon_Web_MyCoupon(req, query));
  }

  @Get('/noReceived')
  @util_ApiResponse_Base({
    dataType: 'dataType_list',
    summary: '查询未领取的优惠券',
  })
  async couponWeb_NoReceived(@Req() req: IRequest, @Query() query: Others_PageClass_Base) {
    return util_Index_ReturnContent(await this.coupon_Service.coupon_Web_NoReceived(req, query));
  }

  @Get('/receive')
  @util_ApiResponse_Base({
    dataType: 'dataType_string',
    summary: '一键领取优惠券',
    type: '领取成功',
    description: '领取成功',
  })
  async couponWeb_receive(@Req() req: IRequest) {
    return util_Index_ReturnContent(await this.coupon_Service.coupon_Web_receive(req));
  }
}
